<html>
<head><meta charset="utf-8"><title>Summarizing the RFC · project-ffi-unwind · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/index.html">project-ffi-unwind</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Summarizing.20the.20RFC.html">Summarizing the RFC</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201679679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Summarizing%20the%20RFC/near/201679679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nell Shamrell-Harrington <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Summarizing.20the.20RFC.html#201679679">(Jun 23 2020 at 01:19)</a>:</h4>
<p>Hello all! I'm looking to provide a very brief and very high level summary of <a href="https://github.com/rust-lang/rfcs/pull/2945">https://github.com/rust-lang/rfcs/pull/2945</a> on this week's "This Week in Rust" podcast. Does this summary sound accurate?</p>
<ul>
<li>Unwinding is what happens when a program you are running encounters an exception. When the exception is thrown, the runtime for the program will unwind the stack and essentially traverse backward through it, calling any clean up or error recovery code.</li>
<li>
<p>Even though Rust does not implement exceptions the way languages like Java or C++ do, it does support unwinding under two conditions<br>
1) When rust code panics, it unwinds the stack<br>
2) When Rust is interfacing with another programming language with exceptions, like C++, it can call functions in that language to unwind the stack.</p>
</li>
<li>
<p>Currently, when foreign code - that means code not written in Rust - invokes Rust code and the Rust code panics and unwinds, the result of that unwind will not be available to the foreign code.</p>
</li>
<li>Likewise when Rust code calls foreign code and that foreign code throws an exception and unwinds, the result of that unwind will not be available to the Rust code</li>
<li>This RFC seeks to change that by defining an ABI - or Application Binary Interface - that would enable unwinding from other languages (such as C++) into Rust frames and from Rust into other languages.</li>
</ul>



<a name="201689629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Summarizing%20the%20RFC/near/201689629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Summarizing.20the.20RFC.html#201689629">(Jun 23 2020 at 05:42)</a>:</h4>
<p>Looking forward to the podcast!</p>
<p>This RFC is somewhat more limited than that; it won't provide a way for Rust to actually access an exception object itself thrown by C++, or for C++ to access a <code>panic</code> object. The <code>"C unwind"</code> ABI will simply make it safe to unwind C++ frames with a Rust <code>panic</code> (or Rust frames with a C++ exception), which some crates are already doing even though it is currently undefined behavior. In order to recover from a <code>panic</code> and resume normal execution, the <code>panic</code> must still be caught by Rust, not by C++; similarly, C++ exceptions can only be caught by C++.</p>
<p>Otherwise, that summary seems fairly good, though I'd suggest a few tweaks. We're defining a new ABI string, but not a new ABI per se; also, I would say "throws an exception" rather than "encounters an exception". (You could also combine the first two bullets; it's probably sufficient to define unwinding as "how C++ exceptions and Rust <code>panic</code>s are implemented.")</p>



<a name="201749298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Summarizing%20the%20RFC/near/201749298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nell Shamrell-Harrington <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Summarizing.20the.20RFC.html#201749298">(Jun 23 2020 at 16:29)</a>:</h4>
<p>That is very helpful, thank you!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>